#ifndef OSGI_CORE_IDASERVICE_H__
#define OSGI_CORE_IDASERVICE_H__

#include "osgi-predefined.h"
#include <string>
#include <map>




OSGI_NAMESPACE_BEGIN

enum DBType
{
    KINGBASE = 0,
    DM = 1,
    SHENTONG = 2,
    SQLITE =3
};

typedef std::map<std::string, std::string> OPTIONALCOFIG;

typedef std::map<std::string, std::string> DBSTATUS;

//DB服务类
#define SID_DBService                 "SID_DBService"
#define IID_DBService                 "IID_DBService"
OSGI_INTERFACE IDBService : public IService
{
    /**
    register a monitor handle, which will collect the monitored data from the plugin, when monitor plugin want to get the monitor data.
    @param uri the uri string
    @param phandle, it is the callback funtion, which will trigger the invoke, when http server post event.
    @param description,  it is the plugin description, which will display in the default index.html.
    @return, when register is success, it's value is true, or it is false.
    */
    virtual int MKRAPI RegisterDatabase(const char *dbName,
                                        DBType fileType,
                                        const char* driver,
                                        const char* serverIP,
                                        int port,
                                        const char* dbbase,
                                        const char* username,
                                        const char* pwd,
                                        int socketBufferSize,
                                        int fetchBufferSize,
                                        char* description,
                                        OPTIONALCOFIG* opt) = 0;

    /**
    register a monitor handle, which will collect the monitored data from the plugin, when monitor plugin want to get the monitor data.
    @param bundleName the plugin name
    @param phandle, it is the callback funtion, which will trigger the invoke, when http server post event.
    @param data,  it is the monitored data that the plugin want to report.
    @param description,  it is the plugin description, which will display in the default index.html.
    @return the monitor item, which can get the related handle and data.
    */
    virtual int MKRAPI UnregisterDatabase(const char* dbName) = 0;

    virtual int MKRAPI restartDB(const char* dbName) = 0;

    virtual int MKRAPI testConnectAllDB(void* hdbc) = 0;

    virtual int MKRAPI insertDB(void* hdbc, char** insertStr) = 0;

    virtual int MKRAPI deleteDB(void* hdbc, char** deleteStr) = 0;

    virtual int MKRAPI modifyDB(void* hdbc, char** modifyStr) = 0;

    virtual int MKRAPI queryDB(void* hdbc, char** queryStr) = 0;

    virtual int MKRAPI restoreOdbcConfig() = 0;
};

OSGI_NAMESPACE_END

#endif // OSGI_CORE_IDBSERVICE_H__
